<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="com.google.appengine.api.datastore.DatastoreService"%>
<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory"%>
<%@ page import="com.google.appengine.api.datastore.Entity"%>
<%@ page import="com.google.appengine.api.datastore.FetchOptions"%>
<%@ page import="com.google.appengine.api.datastore.Key"%>
<%@ page import="com.google.appengine.api.datastore.KeyFactory"%>
<%@ page import="com.google.appengine.api.datastore.Query"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="java.util.List"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<html>
	<head>
		<meta charset="utf-8">
    	<title>GoW</title>
    	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    	<meta name="description" content="">
    	<meta name="author" content="">
    	
    	<style type="text/css">
      		body {
        		padding-top: 60px;
        		padding-bottom: 40px;
      		}
    	</style>
		<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
		<link type="text/css" rel="stylesheet" href="/stylesheets/bootstrap.min.css" media="screen">
	</head>

	<body>
		<c:import url="/WEB-INF/JSP/menu.jsp" />
	
		<div class="container">
			<h1>Hello!</h1>

			<c:if test="${not empty user}">
				<p>
					Hello, ${fn:escapeXml(${user.nickname})}! (You can <a
					href="${logoutUrl}">sign out</a>.)
				</p>
			</c:if>
			
			<c:if test="${empty user}">
				<p>
					Hello! <a href="${logoutUrl}">Sign in</a> to include your name with
					greetings you post.
				</p>
			</c:if>
			
			<c:if test="${not empty posts}">
				<p>Guestbook '${fn:escapeXml(guestbookName)}' has no messages.</p>
			</c:if>

			<c:if test="${empty posts}">
				<p>Berichten:</p>
			</c:if>

			<c:if test="${empty posts}">
				<p>Geen posts beschikbaar</p>
			</c:if>


			<c:if test="${not empty posts}">
				<c:forEach var="post" items="${posts}">
					<p>
						Geplaats door:
						<c:if test="${not empty post.user}">${post.user.userName}</c:if>
						<c:if test="${not empty post.user}">anonieme gebruiker</c:if>
					</p>
					<div class="row">
						<div class="span12">
							<blockquote>${fn:escapeXml(post.content)}</blockquote>
						</div>	
					</div>
				</c:forEach>
			</c:if>

			<form action="/sign" method="post">
    			<div><textarea name="content" rows="3" cols="60"></textarea></div>
    			<div><input type="submit" value="Post Greeting"/></div>
    			<input type="hidden" name="guestbookName" value="${fn:escapeXml(guestbookName)}"/>
			</form>
			<p>An anonymous person wrote:</p>

			<c:if test="${empty user} }">
				<a href="/registration">Registration</a>
			</c:if>

			<form action="/sign" method="post">
				<div>
					<textarea name="content" rows="3" cols="60"></textarea>
				</div>
				<div>
					<input type="submit" value="Post Greeting" />
				</div>
				<input type="hidden" name="guestbookName" value="${fn:escapeXml(guestbookName)}" />
			</form>

			<form action="/guestbook.jsp" method="get">
				<div>
					<input type="text" name="guestbookName" value="${fn:escapeXml(guestbookName)}" />
				</div>
				<div>
					<input type="submit" value="Switch Guestbook" />
				</div>
			</form>
		</div>

		<script src="http://code.jquery.com/jquery.js"></script>
		<script src="/js/bootstrap.min.js"></script>
	</body>
</html>
